<?php
namespace app\common\model;

use think\Model;
class User extends Model
{
  protected $insert =["ctime","nickname"];

  //md5加密
  protected function setPwdAttr($value)
  {
    return substr(md5($value),8);
  }

  //自动写入注册时间
  protected function setCtimeAttr()
  {
    return time();
  }
  //自动写入默认昵称
  protected function setNicknameAttr()
  {
    $rand = rand(111,999);
    return "用户_" .time() .$rand;
  }
}